﻿using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace Yappi.Tests
{
    public class ManualINPC:INotifyPropertyChanged
    {
        private static readonly IEqualityComparer<String> StringComparer = EqualityComparer<String>.Default;
        private static readonly IEqualityComparer<int> IntComparer = EqualityComparer<int>.Default;
        private static readonly IEqualityComparer<Object> ObjectComparer = EqualityComparer<Object>.Default;

        public ManualINPC(int ivalue,Object ovalue, String svalue)
        {
            _intProperty = ivalue;
            _objectProperty = ovalue;
            _stringProperty = svalue;
        }

        public ManualINPC()
        {
            
        }
        private int _intProperty;

        public virtual int IntProperty
        {
            get { return _intProperty; }
            set
            {
                if (IntComparer.Equals(_intProperty,value)) return;
                
                _intProperty = value;

                OnPropertyChanged("IntProperty");
            }
        }

        private object _objectProperty;
        
        public virtual object ObjectProperty
        {
            get { return _objectProperty; }
            set
            {
                if (ObjectComparer.Equals(_objectProperty, value)) return;
                
                _objectProperty = value;

                OnPropertyChanged("ObjectProperty");
            }
        }

        private string _stringProperty;

        public virtual String StringProperty
        {
            get { return _stringProperty; }
            set
            {
                if (StringComparer.Equals(value,_stringProperty)) return;

                _stringProperty = value;

                OnPropertyChanged("ObjectProperty");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
